import React, { useState, useCallback } from 'react';

export default function() {
    const [num, setNum] = useState(0);

    const add = useCallback(() => {
        setNum(val => val + 1);
    });

    return <>
        <div>{num}</div>
        <button onClick={add}>Add</button>
    </>;
}